﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain;

namespace Data.Repositories
{
    public class RoleRepository
    {
        public User GeUserByUserName(string username)
        {
            //return Repository.Repo.Single<User>(u => u.UserName == username);
            return null;
        }

        public Role GeRoleByName(string name)
        {
            //return Repository.Repo.Single<Role>(r => r.RoleName.ToLower() == name.ToLower());
            return null;
        }

        public void Save()
        {

        }

        public int Add(string name)
        {
            //return (int)Add(new Role { RoleName = name, Description = name });
            return 0;
        }

        public int Delete(Role role)
        {
            //return Repository.Repo.Delete<Role>(role.Id);
            return 0;
        }

        public void AddUserToRole(string u, string r)
        {
            //User user = GeUserByUserName(u);
            //if (user == null)
            //    return;
            //Role role = GeRoleByName(r);
            //if (role == null)
            //    return;
            //var uir = new TJoin { UserID = user.Id, RoleID = role.Id };
            //Repository.Repo.Add(uir);
        }

        public int RemoveUserFromRole(string u, string r)
        {
            //User user = GeUserByUserName(u);
            //if (user == null)
            //    return 0;
            //Role role = GeRoleByName(r);
            //if (role == null)
            //    return 0;

            //return Repository.Repo.DeleteMany<TJoin>(uir => uir.RoleID == role.Id && uir.UserID == user.Id);
            return 0;
        }

        public IEnumerable<User> FindUsersInRole(string roleName, string usernameToMatch)
        {
            //Role role = GeRoleByName(roleName);
            //var i = role.Users.AsQueryable();
            //var x = from u in i where SqlMethods.Like(u.UserName, usernameToMatch) select u;
            //return x.ToArray();
            return null;
        }

        public List<Role> FindAllRoles()
        {
            //return Repository.Repo.All<Role>().ToList();
            return null;
        }

    }
}
